#include<iostream>
using namespace std;
#include<vector>
class Solution {
public:
    void setZeroes(vector<vector<int>>& matrix) {
        int m = matrix.size(), n = matrix[0].size();
        vector<int> line(m, 0), row(n, 0);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                line[i] += matrix[i][j] != 0;
                row[j] += matrix[i][j] != 0;
            }
        }
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                if (line[i] == n && row[j] == m)
                    continue;
                else
                    matrix[i][j] = 0;
            }
        }
        return;
    }
};